import datetime
import pytz

utc_tz = datetime.timezone.utc
cst_tz = datetime.timezone(datetime.timedelta(hours=8))
with open('x_log_utc_read_as_cst.tmp.txt', 'a+') as xfile:
    xdt_now = datetime.datetime.utcnow()
    xdt_now = xdt_now.replace(tzinfo=utc_tz)
    xdt_str = xdt_now.isoformat()
    xfile.write(xdt_str + '\n')

    xfile.seek(0)
    while True:
        xline = xfile.readline()
        if len(xline) == 0:
            break
        xdt_str = xline[:-1]
        try:
            xdt = datetime.datetime.fromisoformat(xdt_str)
            xdt = xdt.astimezone(cst_tz)
            print(xdt_str, '=>', xdt.isoformat(), xdt.tzname())
        except ValueError as ex:
            print(xdt_str, '=>', repr(ex))
